const { envList } = require('../../envList');

// pages/me/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    openid: '',
    showUploadTip: false,
    islogin:true,
    rotated:false,
    imgStyle:'',
    infolist:[
        {
            imgs:'../../images/个人信息修改.png',
            name:"个人信息修改",
            pathgo:'../editinformation/index'
        },
        {
            imgs:'../../images/关注-置灰.png',
            name:"我的关注",
            pathgo:'../attention/attention'
        },
        {
            imgs:'../../images/百应AI平台.png',
            name:"AI答疑",
            pathgo:'../aiquestion/index'
        },
        {
           imgs:'../../images/我的反馈.png',
           name:"我的反馈",
           pathgo:'../feedback/feedback'
        }
    ],
    userInfo:''
  },

  bindGetUserInfo(e){
  console.log(e)
  var that = this;
    if (e.detail.errMsg == "getUserInfo:ok") {
      wx.setStorage({
        key: "userinfo",
        data: e.detail.userInfo
      })
      this.setData({ 
        userInfo: e.detail.userInfo,
        islogin:false
       });
    }
  wx.cloud.callFunction({
      name:'getopenid',
      complete:res=>{
          console.log(res)
        wx.setStorage({
            key:'openid',
            data:res.result.openid
        })
        this.setData({
            openid:res.result.openid
        })
      }
  })
  },
  onLoad:function(){
    var that = this;
    wx.getStorage({
      key: 'openid',
      success: function (res) {
        that.setData({
             openid: res.data,
             islogin:false
        });
      },
      fail: function (res) {
        console.log(res)
      }
    })
  },
    //监听页面显示
    onShow:function(){
        if(typeof this.getTabBar==='function'&&this.getTabBar()){
            this.getTabBar().setData({
                select:2
            })
        }
    },
    pathGo(e){
        const {pathgo}=e.currentTarget.dataset
        wx.navigateTo({
          url: pathgo,
        })
    },
});
